package com.yn.front.zy;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yn.common.model.zy.TInspectionItemDO;
import com.yn.common.page.BasePage;
import com.yn.common.request.sc.PageParamRequest;
import com.yn.common.response.sc.BaseResult;
import com.yn.service.zy.TInspectionItemService;
import com.yn.service.zy.model.dto.TInspectionItemDTO;
import com.yn.service.zy.model.query.TInspectionItemQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/tinspectionitem")
@Api(tags = "检查项相关接口")
@Slf4j
public class TInspectionItemController {
    @Autowired
    private TInspectionItemService tInspectionItemService;

    /**
     * 分页获取检查项信息
     * @param query
     * @param
     * @return
     */
   /* @GetMapping("/list-page")
    @ApiOperation("分页获取检查项信息")
    public BaseResult listPage(TInspectionItemQuery query, BasePage basePage){
        IPage<TInspectionItemDTO> tInspectionItemDTOIPage = tInspectionItemService.listPage(query,basePage);

        return BaseResult.success(tInspectionItemDTOIPage);
    }*/

    @GetMapping("/list-page")
    @ApiOperation("分页获取检查项信息")
    public BaseResult<BasePage<TInspectionItemDTO>> listPage1(TInspectionItemQuery query, PageParamRequest pageRequest){
        log.info("分页查询检查项入参:{}",query);
        return BaseResult.success(tInspectionItemService.listPage1(query,pageRequest));
    }

    /**
     * 获取检查项详情
     * @param itemPriceId
     * @return
     */
    @GetMapping("/info")
    @ApiOperation("获取检查项详情")
    public BaseResult info(@RequestParam(value = "itemPriceId",required = true)
                           @NotNull(message = "请选择检查项")
                           @ApiParam(value = "检查项价格id",required = true)Integer itemPriceId){
        TInspectionItemDTO tInspectionItemDTO = tInspectionItemService.getInfo(itemPriceId);

        return BaseResult.success(tInspectionItemDTO);
    }

}
